package ch.trainingtest.dao;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.TypedQuery;

import ch.trainingtest.base.dao.BaseDao;
import ch.trainingtest.common.NamedQueryConstants;
import ch.trainingtest.entity.Task;
import ch.trainingtest.entity.TaskHistory;

@Stateless
public class TaskHistoryDao extends BaseDao<TaskHistory> {
	public List<TaskHistory> getHistoryOfTask(Task task) {
		TypedQuery<TaskHistory> query = getEm().createNamedQuery(NamedQueryConstants.TASKHISTORY_GET_ALL_HISTORY_BASE_ON_TASKID, TaskHistory.class);
		query.setParameter("Task", task);
		List<TaskHistory> result = query.getResultList();
		return result;
	}
	
	public void addHistory(TaskHistory taskHistory) {
		persist(taskHistory);
	}
}
